<?php

/**
 * Search short summary.
 *
 * Search description.
 *
 * @version 1.0
 * @author GALAXY
 */
class Search extends ShopSearch_Controller
{
    public function __construct()
    {
        parent::__construct();
        $this->load->Model('Goods_model');
    }

    public function index()
    {
        //$one= $this->convertUrlQuery('material=4&material=1');
        //p($one);
        $arr_query= $this->convertUrlQuery($_SERVER['QUERY_STRING']);

        $_mark=0;
        $data['del_condition']=$this->del_condition($arr_query,$_mark);

        $data["_mark"]=$_mark;
        $key=$this->input->get('key');
        $data['del_all_condition']=!empty($key)?site_url('search/index')."?key=".$key:site_url('search/index');
        $mark=array('material'=>0,'color'=>0,'style'=>0);
        $where_sql=$this->get_sql_where($arr_query,$mark);
        $data['mark']=$mark;


        $cupge=$this->input->get('page');
        $cupge=empty($cupge) || $cupge=="0"?1:$cupge;
        $pagesize=12;
        $goodslist=$this->Goods_model->get_page($cupge,$pagesize,"*","goods","order by weight desc,goods_id desc","goods_id","where is_del=0 and is_on_sale=1 $where_sql","");
        $this->load->library('page');
        $p=new Page();
        $data['goodsList']=arrayToObject($goodslist['objlist']);
        $p->init($goodslist['count'][0]->_count,8,$cupge,$pagesize,site_url('search/index'));
        $data['links']=$p->showPages(1);
        $this->load->view('Pre/search/index.html',$data);
    }
}